import { requestClient } from '#/api/request';

export namespace RepairApi {
  export type Params = object;
  export interface GetRepairReq {
    pageNum: number;
    pageSize: number;
  }

  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date;
    remark: string;
    params: Params;
    repairId: number;
    repairCode: string;
    repairName: null;
    machineryId: number;
    machineryCode: string;
    machineryName: string;
    machineryBrand: string;
    machinerySpec: null;
    machineryTypeId: number;
    requireDate: Date;
    finishDate: null;
    confirmDate: null;
    repairResult: string;
    acceptedBy: null;
    acceptName: null;
    confirmBy: null;
    confirmName: null;
    status: string;
    attr1: null | string;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface GetRepairListResp {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取类型列表
export const getRepairList = (params: RepairApi.GetRepairReq) =>
  requestClient.get<RepairApi.GetRepairListResp>('/mes/dv/repair/list', {
    params,
  });

// 修改保养项目设置
export const updateRepair = (data: RepairApi.Row) =>
  requestClient.put<RepairApi.GetRepairListResp>('/mes/dv/repair', data);

// 增加保养项目设置
export const addRepair = (data: RepairApi.Row) =>
  requestClient.post<RepairApi.GetRepairListResp>('/mes/dv/repair', data);

// 删除保养项目设置
export const deleteRepair = (id: string) =>
  requestClient.delete<RepairApi.GetRepairListResp>(`/mes/dv/repair/${id}`);
